Skip to content

Pin db threads to cores#2801

Merged
coolreader18 merged 27 commits into
masterfrom
noa/pin-threads
Jun 6, 2025
Merged

Pin db threads to cores#2801
coolreader18 merged 27 commits into
masterfrom
noa/pin-threads

Conversation

@coolreader18

@coolreader18 coolreader18 commented May 28, 2025

Copy link
Copy Markdown
Contributor

Description of Changes

This pins the threads that wasm instances run on, tokio worker threads, and rayon threads to specific cores, in the following arrangement:

  • Module instance threads: 1/8 of available cores, with a round-robin-ish repinning system that tries to ensure that if there are >nproc/8 databases running, all the database cores will have roughly the same number of instances pinned to them.
  • tokio worker threads: 4/8 of available cores, with tokio::runtime::Builder::num_threads set to the same number.
  • rayon threads: 1/8 of available cores.
  • tokio blocking threads: on linux, all of them have their sched_setaffinity set to a cpuset of the remaining 3/8.

API and ABI breaking changes

Expected complexity level and risk

Testing

  • Bot-tested and used in production for BitCraft.

@coolreader18 coolreader18 marked this pull request as ready for review June 3, 2025 17:28
Comment thread crates/core/src/util/jobs.rs
Comment thread crates/core/src/util/jobs.rs
Comment thread crates/core/src/util/jobs.rs Outdated
Comment thread crates/core/src/util/jobs.rs
Comment thread crates/core/src/util/jobs.rs
Comment thread crates/core/src/host/host_controller.rs
Comment thread crates/core/src/host/host_controller.rs
Comment thread crates/core/src/host/module_host.rs Outdated
Comment thread crates/core/src/host/module_host.rs Outdated
Comment thread crates/core/src/host/module_host.rs Outdated
@bfops bfops added release-any Can land in any release window. Will not block a release deployment. performance A PR/Issue related to improving performance of stdb labels Jun 3, 2025
@coolreader18

Copy link
Copy Markdown
Contributor Author

Ah. I think the failure is possibly because DynModuleHost::exit() no longer actually stops things from running.

Comment thread crates/core/src/host/host_controller.rs
Comment thread crates/core/src/host/host_controller.rs Outdated
Comment thread crates/core/src/startup.rs Outdated
Comment thread crates/core/src/util/jobs.rs
coolreader18 and others added 5 commits June 6, 2025 12:40
Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Signed-off-by: Noa <coolreader18@gmail.com>
@coolreader18 coolreader18 enabled auto-merge June 6, 2025 18:17
@coolreader18 coolreader18 added this pull request to the merge queue Jun 6, 2025
Merged via the queue into master with commit 967e82a Jun 6, 2025
18 of 19 checks passed
@coolreader18 coolreader18 deleted the noa/pin-threads branch June 6, 2025 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance A PR/Issue related to improving performance of stdb release-any Can land in any release window. Will not block a release deployment.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants